<!doctype html>
<html>
<head>
    <link href="/stylesheets/base.css" rel="stylesheet">
    <link href="/stylesheets/style.css" rel="stylesheet">
    <!-- <link href="/stylesheets/mood.css" rel="stylesheet"> -->
    <script src="/javascripts/baiduTemplate.js"></script>
</head>
</body>
</html>

<%for(var i=0; i < list.length; i++){%>
  
  <div class="oneblog">
      <h2><a title="路·过-喜欢在路上" href="/"><%= list[i]["chapterName"]%></a></h2>
      <figure><img src=<%= list[i]["imgPath"] %> border='0' width='120' height='120' alt='路·过-喜欢在路上'></figure>
      <ul class="nlist">
          <p><%= list[i]["chapterDes"]%>...</p>
          <a title="路·过-喜欢在路上" href="/detail/<%= list[i]['blogId']%>" target="_blank" class="readmore" onclick=showDetail(event,<%= list[i]["chapterId"] %>)>阅读全文>></a>
      </ul>
      <p class="dateview">
          <span>发布时间：<%= list[i]["publishTimer"]%></span>
          <span>作者：<%= list[i]["author"]%></span>
          <span>分类：[<a href="/">悠客</a>]</span>
          <span class="nl">浏览（<%= list[i]["views"]%>)</span>
          <span class="n2">评论（<a href="/">0</a>）</span>
          <div class="line"></div>
      </p>
  </div>
<%}%>

<script>
  $.get("http://localhost:3000/detail.ejs", function(data) {
      var data={
          "title":'欢迎使用baiduTemplate',
          "list": JSON.parse(data)
      };
      var bt=baidu.template;
      var html=bt('t:_1234-abcd-1',data);
      document.getElementById('result').innerHTML=html;
      console.log(data);
  })

  function showDetail(e, chapterId) {
      e.preventDefault();
      console.log(chapterId);
      window.location = "http://localhost:3000/detail?chapterId=" + chapterId;
    //   fetch("http://localhost:3000/detail?chapterId=?"+chapterId).then(res=>{
    //   return res.text()
    // }).then(res=>{
    //   console.log(res)
    // })
  }


</script>

<!-- <!DOCTYPE html>
<html>

<head>
  <link rel='stylesheet' href='/stylesheets/style.css' />
  <link rel="stylesheet" href="/stylesheets/common.css">
</head>

<body>
  <ul>
    <%for(var i=0;i<list.length;i++){%>
      <li>
        <%=list[i]["author"]%>
      </li>
      <%}%>
  </ul>
  <img src="/images/hewen.jpg" alt=""> -->
</body>
</html>